package com.bj58.mis.apm.server.statistics.query;

import com.bj58.mis.apm.server.core.common.consts.CommonConsts;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 * @author: zhangfx
 * @create: 2018-06-25 18:27
 **/
@ApiModel(value = "分页查询条件")
public class PageInfo {
    @ApiModelProperty(value = "查询页码")
    private int page;
    @ApiModelProperty(value = "每页条数")
    private int limit;

    public int getPage() {
        return page<=0? 1 : page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getLimit() {
        return this.limit <= 0 ? CommonConsts.DEFAULT_QUERY_LIMIT : this.limit;
    }

    public void setLimit(int limit) {
        this.limit = limit;
    }

    public int getOffset(){
        int offset = (this.getPage()-1)*this.getLimit();
        return offset < 0 ? 0 : offset;
    }
}
